#include "Background.h"
#include <string>

using namespace std;

Background::Background(GameState *gameState, string texture) : GameObject(gameState){
	m_texture = gameState->getTextureManager().getTexture(texture);
	setLayer(9);
}

void Background::update(double dt){
	
}


void Background::draw(){
	float width = m_gameState->camera.widthUnits;
	float height = m_gameState->camera.heightUnits;



	sf::Texture::bind(m_texture);

	glPushMatrix();
	{
		glTranslatef(m_gameState->camera.posX, m_gameState->camera.posY, 0); 
		glScalef(width, height, 1);
		glBegin(GL_QUADS);
		{
			glTexCoord2f(0.0f, 1.0f); glVertex3f( -0.5f, -0.5f, -10.0f);
			glTexCoord2f(1.0f, 1.0f); glVertex3f( 0.5f, -0.5f, -10.0f);
			glTexCoord2f(1.0f, 0.0f); glVertex3f( 0.5f, 0.5f, -10.0f);
			glTexCoord2f(0.0f, 0.0f); glVertex3f( -0.5f, 0.5f, -10.0f);
		}
		glEnd();
	}
	glPopMatrix();

	sf::Texture::bind(NULL);
}


